package com.heima.behavior.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.apis.behavior.ApUnLikeBehaviorControllerApi;
import com.heima.behavior.service.ApUnLikeBehaviorService;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.behavior.pojos.ApUnlikesBehavior;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/unlike_behavior")
public class ApUnLikesBehaviorController implements ApUnLikeBehaviorControllerApi {
    @Autowired
    private ApUnLikeBehaviorService apUnLikeBehaviorService;

    @PostMapping
    @Override
    public ResponseResult unLike(@RequestBody UnLikesBehaviorDto dto) {
        return apUnLikeBehaviorService.unLike(dto);
    }

    @GetMapping("/one")
    @Override
    public ApUnlikesBehavior findUnLikeByArticleIdAndEntryId(@RequestParam("articleId") Long articleId,@RequestParam("entryId") Integer entryId) {
        return apUnLikeBehaviorService.getOne(Wrappers.<ApUnlikesBehavior>lambdaQuery().eq(ApUnlikesBehavior::getArticleId , articleId)
        .eq(ApUnlikesBehavior::getEntryId , entryId));
    }
}
